//package com.ustcinfo.study.mr.sg;
//
//import org.apache.hadoop.fs.Path;
//import org.apache.hadoop.io.IntWritable;
//import org.apache.hadoop.io.Text;
//import org.apache.hadoop.mapreduce.Job;
//import org.apache.hadoop.mapreduce.Mapper;
//import org.apache.hadoop.mapreduce.Reducer;
//import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
//import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
//
//import java.io.IOException;
//
///*
//* @author   hesong
//* @ClassName  WordlCount
//* */
//public class WordlCount {
//                                                     //入参       出参
//                                                     //key  value  key  value
//    private static class MyMapper extends Mapper<Object,Text,Text,IntWritable>{
//        private static final IntWritable count = new IntWritable(1);
//        protected void map(Object key,Text value,Context context) throws IOException, InterruptedException {
//            //读取一行内容
//            String line = value.toString();
//            //拆分存入数组
//            String[] arr = line.split(" ");
//            //遍历
//            for (int i = 0;i<arr.length;i++){
//               Text word = new Text();
//               word.set(arr[i]);
//               //通过context临时保存到本地磁盘
//               context.write(word,count);
//            }
//        }
//    }
//    private static class MyReducer extends Reducer<Text,IntWritable,Text,IntWritable>{
//        @Override
//        protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
//            int sum = 0;
//            //遍历
//            for (IntWritable val:values){
//                sum += val.get();
//            }
//            context.write(key,new IntWritable(sum));
//        }
//    }
//
//    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
//        Job job = Job.getInstance();
//        job.setJobName("hesong_word_count");
//        job.setJarByClass(WordlCount.class);
//        job.setMapperClass(MyMapper.class);
//        job.setCombinerClass(MyReducer.class);
//        job.setOutputKeyClass(Text.class);
//        job.setOutputValueClass(IntWritable.class);
//        FileInputFormat.addInputPath(job,new Path(args[0]));
//        FileOutputFormat.setOutputPath(job,new Path(args[1]));
//        int status = job.waitForCompletion(true)?0:1;
//        System.exit(status);
//
//
//    }
//}
//
//
//
//
//
//
//
//
//
//
